<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:96:"E:\phpstudy2016\WWW\shopsum\public/../application/admin\view\count\commencement_formalities.html";i:1520916701;s:57:"E:\phpstudy2016\WWW\shopsum\application\public\admin.html";i:1520912952;}*/ ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数据字典-<?php echo \think\Config::get('title'); ?></title>
    <link rel="stylesheet" href="../../../../public/static/public/boo3/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css">
    <link rel="stylesheet" href="__PUBLIC__/index/css/sytle.css">
    <script src="__PUBLIC__/public/js/jquery-2.1.4.min.js"></script>
    <script src="__PUBLIC__/public/js/vue.min.js"></script>
    <script src="__PUBLIC__/public/js/jquery.transit.js"></script>
    <script src="__PUBLIC__/public/js/jquery.timers-1.2.js"></script>
    <script src="__PUBLIC__/public/layer-v3.1.1/layer/layer.js"></script>
    <style>
        #container{
            padding: 0 30px;
        }
        nav{
            background-color: #f5f5f5;
            padding: 10px 20px;
            z-index: 99;
            margin-bottom: 15px;
        }
        @media screen and (max-width: 800px) {
            nav{
                display: none;
            }
        }
    </style>
    <script>
        var DINDEX = '/admin/index';
        var DUSER = '/admin/user';
        var DADMIN = '/admin';
        var DJOURNALISM = '/admin/journalism';
        var DCOUNT = '/admin/count';
        //页面
        function yeMian(url,fn = 1,this_json = {title:'信息',area:['400px','450px']}) {

            var index = layer.open($.extend({type:2,content:url,end:function () {
                    if(typeof fn != 'number' ){
                        fn();
                    }
                }},this_json));
        }

        //看图
        function loock_img(url) {
            url = url.data('img');
            if((typeof url) != 'string'){
                layer.msg('没有数据查看',{icon:2});
                return;
            }
            layer.open({
                type:2,
                title:false,
                closeBtn:false,
                area:['100%','100%'],
                content:"<?php echo url('loock/index',['on'=>'true']); ?>?url="+url
            })
        }
    </script>
    
<link rel="stylesheet" href="__PUBLIC__/admin/css/index.dictionaries.css">


</head>
<body>

<nav>
       <small><i class="fa fa-institution"></i></small> 首页 > <?php echo \think\Config::get('this_user_name'); if(\think\Request::instance()->param('on') == 'true'): ?>
       <a href="javascript:;" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name));"  title="关闭当前页面" class="btn btn-xs btn-default fa-pull-right " style="margin-left: 10px"><i class="fa fa-close"></i></a>
        <?php endif; ?>
    <a href="javascript:location.reload();" title="刷新" class="btn btn-xs btn-success fa-pull-right"><i class="fa fa-refresh"></i></a>
</nav>

<div id="container">


    <div class="clearfix"></div>
    <div style="height: 20px;"></div>
    <div class="table-responsive" id="header">
        <table class="table table-bordered table-hover" v-cloak>
            <thead>
            <tr class="active">
                <th colspan="12" class="text-left">
                    <a href="javascript:;" @click="text()" class="btn btn-info btn-sm"><i class="fa fa-plus"></i> <?php echo lang('添加'); ?></a>
                    <span>
                        &nbsp;总费用 {{sum.toFixed(2)}} &nbsp;&nbsp;&nbsp;
                        总支付 {{chu.toFixed(2)}}&nbsp;&nbsp;&nbsp;
                        总未付 {{(sum-chu).toFixed(2)}}
                    </span>
                    <span class="fa-pull-right">总 <strong>{{list.length}}</strong> 条</span>
                </th>
            </tr>
            <tr class="active">
                <th><?php echo lang('序号'); ?></th>
                <th><?php echo lang('手续名称'); ?></th>
                <th><?php echo lang('办理手续文号'); ?></th>
                <th><?php echo lang('开具证明单位'); ?></th>
                <th><?php echo lang('办理费用'); ?></th>
                <th><?php echo lang('是否支付'); ?></th>
                <th><?php echo lang('未支付费用'); ?></th>
                <th><?php echo lang('描述'); ?></th>
                <th><?php echo lang('状态'); ?></th>
                <th><?php echo lang('操作'); ?></th>
            </tr>
            </thead>
            <tbody>
            <template v-for="(key,index) in list">
               <tr>
                   <td>{{index+1}}</td>
                   <td>{{key.staname}}</td>
                   <td>{{key.staindex}}</td>
                   <td><a href="javascript:;" onclick="loock_img($(this))" :data-img="key.stacompany_img" title="查看证据">{{key.stacompany}}</a></td>
                   <td>{{key.stamoney}}</td>
                   <td>
                       <a href="javascript:;" title="查看证据" @click="loca('/admin/count/loock/on/true/id/'+key.staid)">
                            {{key.appmoney}}
                       </a>
                   </td>
                   <td>

                       {{(key.stamoney - key.appmoney).toFixed(2)}}

                   </td>
                   <td>{{key.statext}}</td>
                   <td>
                       {{key.stastate == 0?'待办理':key.stastate == 1?'完成':key.stastate == 2?'拒绝':key.stastate == 3?'待审核':'无'}}
                   </td>
                   <td>
                       <template v-if="key.stastate == 0"><!--待办理-->
                             <a href="javascript:;" class="btn btn-xs" title="<?php echo lang('办理'); ?>" @click="url(key.staid)"><i class="fa fa-cog"></i></a>
                       </template>
                       <template v-else-if="key.stastate == 2"><!--拒绝-->
                           <a href="javascript:;" title="<?php echo lang('修改'); ?>" @click="addData(key.staid)"><i class="fa fa-edit"></i></a>
                       </template>
                       <template v-else-if="key.stastate == 3"><!--待审核-->
                           <a href="javascript:;" class="btn btn-xs" title="<?php echo lang('通过'); ?>" @click="up(index,1)"><i class="fa fa-check"></i></a>
                           <a href="javascript:;" class="btn btn-xs" title="<?php echo lang('拒绝'); ?>" @click="up(index,2)"><i class="fa fa-close"></i></a>
                           <a href="javascript:;" title="<?php echo lang('修改'); ?>" @click="addData(key.staid)"><i class="fa fa-edit"></i></a>
                       </template>
                       <template v-else-if="key.stastate == 1">
                           <a href="javascript:;" class="btn btn-xs" title="添加支付" @click="money_add(key.staid)"><i class="fa fa-plus"></i></a>
                           <a href="javascript:;" class="btn btn-xs" title="<?php echo lang('返回到拒绝'); ?>" @click="up(index,2)"><i class="fa fa-mail-reply"></i></a>
                       </template>

                   </td>
               </tr>
            </template>
            </tbody>
        </table>
    </div>
    <div id="Pagination"></div>

</div>


</body>
</html>



<script>
    var app = new Vue({
        el: '#container',
        data: {
            list: [],
            sum:0,
            chu:0

        }
    });

    app.url = (url)=>{
        layer.open({
            type:2,
            title:false,
            closeBtn:false,
            area:['100%','100%'],
            content:"<?php echo url('procedures',['on'=>'true']); ?>?id="+url
        })
    }
    app.loca = (url)=>{
        layer.open({
            type:2,
            title:false,
            closeBtn:false,
            area:['100%','100%'],
            content:url,
            end:function () {
                get_data()
            }
        })
    }

    //审核
    app.up =(i,state)=>{
        layer.confirm("<?php echo lang('是否确定'); ?>",function () {
            $.post("<?php echo url('procedures_up'); ?>",{id:app.list[i].staid,state:state},function (da) {
                console.log(da);
                if (da == 1) {
                    layer.msg("<?php echo lang('成功'); ?>",{icon:1,offset:'rb'});
                    get_data();
                }
                else{
                    layer.msg("<?php echo lang('失败'); ?>",{icon:2,offset:'rb',end:function () {
                            //location.reload();
                        }});
                }
            })
          /*  app.list[i].state = state;*/
        })
    }
    app.text = ()=>{
        layer.prompt({
            title:'请输入名称',
            formType:3
        },function (val,i) {
            $.post("<?php echo url('procedures_name'); ?>",{name:val,id:<?php echo \think\Request::instance()->param('id'); ?>,type:<?php echo \think\Request::instance()->param('type'); ?>},function (da) {
                if (da == 1) {
                    layer.closeAll();
                    get_data();
                    layer.msg("<?php echo lang('成功'); ?>",{icon:1,offset:'rb'});
                }
                else{
                    layer.msg("<?php echo lang('失败'); ?>",{icon:2,offset:'rb'});
                }
            });
        });
    }

    get_data();

    //获取数据
    function get_data() {
        layer.load(1);
        $.get("<?php echo url('count/commencement_formalities',['id'=>\think\Request::instance()->param('id'),'type'=>\think\Request::instance()->param('type')]); ?>", function (da) {
            app.list = da;
             app.sum = 0;
             app.chu = 0;
            $.each(da,function (i,n) {
                app.sum+=parseFloat(n.stamoney);
                //计算总数
                n.appmoney = n.appmoney == null?0:n.appmoney;
                app.chu+=parseFloat(n.appmoney);
            });

            layer.closeAll();
        });
    }

    //查看图片
    app.imgLock = (url)=>{
        layer.open({
            type:2,
            title:'查看文件',
            shift:'3',
            area:['100%','100%'],
            content:url
        })
    }


    //添加详细支付
    app.money_add = (id) => {
        layer.open({
            type:2,
            area:['500px','500px'],
            content:"<?php echo url('money_info'); ?>?id="+id
        })
    }



    //添加内容
    app.addData = (id) => {
        layer.open({
            type:2,
            area:['100%','100%'],
            title:false,
            closeBtn:false,
            content:"<?php echo url('count/procedures',['on'=>'true']); ?>?id="+id
        })
    }
</script>
